package com.google.bitcoin.fees;

import com.google.bitcoin.core.Transaction;

import java.math.BigInteger;

/**
 * This is an immutable FeeSchedule implementation that always returns
 * exactly the fee provided at construction.
 */
public final class FixedFee implements FeeSchedule
{
    private final BigInteger mFee;

    /**
     * @param fee fixed fee to be returned by {@link #getFee}
     *
     * @throws IllegalArgumentException if fee is <tt>null</tt> or non-positive
     */
    public FixedFee(BigInteger fee)
    {
        if (fee == null || fee.signum() < 0)
        {
            throw new IllegalArgumentException("Invalid fixed fee: " + fee);
        }
        mFee = fee;
    }

    /**
     * This implementation unconditionally returns the fee given at
     * construction (the <tt>sendTx</tt> is not interrogated and may be
     * <tt>null</tt>).
     */
    public BigInteger getFee(Transaction sendTx)
    {
        return mFee;
    }
}
